# Copyright 2022 hpmicro
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.13)

set(CUSTOM_GCC_LINKER_FILE D:/cusfile/SDK/sdk/sdk_env_v1.5.0/hpm_sdk/samples/ota/linkers/segger/bootuser.icf)

# set(FLASH_XIP 1)
# set(LINK_TO_FLASH 1)
set(INCLUDE_BOOTHEADER 1)

set(HPM_SDK_NO_NANO_SPECS 1)
set(CONFIG_LWIP 1)
set(CONFIG_ENET_PHY_DP83867 1)
# set(CONFIG_ENET_PHY_RTL8211 1)
# set(CONFIG_ENET_PHY_DP83848 1)
#set(CONFIG_ENET_PHY_RTL8201 1)

find_package(hpm-sdk REQUIRED HINTS $ENV{HPM_SDK_BASE})

if(${CONFIG_ENET_PHY_DP83867})
    sdk_compile_definitions(-DRGMII=1)
    sdk_compile_definitions(-D__USE_DP83867=1)
endif()

if(${CONFIG_ENET_PHY_RTL8211})
    sdk_compile_definitions(-DRGMII=1)
    sdk_compile_definitions(-D__USE_RTL8211=1)
endif()

if(${CONFIG_ENET_PHY_DP83848})
    sdk_compile_definitions(-DRGMII=0)
    sdk_compile_definitions(-D__USE_DP83864=1)
endif()

if(${CONFIG_ENET_PHY_RTL8201})
    sdk_compile_definitions(-DRGMII=0)
    sdk_compile_definitions(-D__USE_RTL8201=1)
endif()

sdk_compile_definitions(-DFLASH_XIP=1)
sdk_compile_definitions(-DBOARD_SHOW_CLOCK=0)

project(boot_user_enet)

sdk_inc(../common)
sdk_inc(inc)
sdk_inc(inc/arch)
sdk_inc(inc/eth)
sdk_inc(inc/app)

sdk_app_src(../common/boot_user.c)
sdk_app_src(../common/ota_api.c)
sdk_app_src(../common/user_signature.c)
sdk_app_src(../common/ota_verify.c)
sdk_app_src(src/arch/ethernetif.c)
sdk_app_src(src/arch/sys_arch.c)
sdk_app_src(src/eth/netconf.c)
sdk_app_src(src/app/tcp_echo.c)
sdk_app_src(src/lwip.c)
sdk_app_src(src/main.c)

generate_ses_project()
